<template>
  <zh-form :model="state.wtTaskVO" label-width="150px">
    <zh-form-input
        :span="24"
        prop="taskName"
        label="任务名称"
        v-model="state.wtTaskVO.taskName"
    ></zh-form-input>
    <zh-form-input
        :span="24"
        prop="taskDesc"
        label="任务描述"
        type="textarea" :row="3"
        v-model="state.wtTaskVO.taskDesc"
    ></zh-form-input>
    <zh-form-select prop="taskType" label="任务类型" placeholder="请选择" :span="24"
                    :options="state.dictData.WTTASKTYPE" v-model="state.wtTaskVO.taskType"
    ></zh-form-select>
    <zh-form-date prop="taskStartTime" label="任务开始日期" format="YYYY-MM-DD"
                  :span="24" v-model="state.wtTaskVO.taskStartTime"></zh-form-date>
    <zh-form-date prop="taskEndTime" label="任务结束日期" format="YYYY-MM-DD"
                  :span="24" v-model="state.wtTaskVO.taskEndTime"></zh-form-date>
    <zh-form-input
        :span="24"
        prop="taskLabel"
        label="任务标签"
        v-model="state.wtTaskVO.taskLabel"
    ></zh-form-input>
    <zh-form-input
        :span="24"
        prop="predictWorkHours"
        label="预估工时"
        v-model="state.wtTaskVO.predictWorkHours"
    ></zh-form-input>
    <zh-form-input
        :span="24"
        prop="remarks"
        label="备注"
        type="textarea" :row="3"
        v-model="state.wtTaskVO.remarks"
    ></zh-form-input>
    <zh-form-input
        v-if="state.wtTaskVO.createWtTaskForChild"
        :span="24"
        prop="taskWorkRatioLabel"
        label="工作量占比"
        v-model="state.wtTaskVO.taskWorkRatioLabel"
    ></zh-form-input>
  </zh-form>
</template>

<script lang="ts" setup name="formForCreateWtTask">
import {defineProps, nextTick, onMounted, reactive,watch} from "vue";
import {theme} from "@/store";
const emits = defineEmits(['update:modelValue']);
const props = defineProps({
  modelValue: {
    type: Object,
    required: false,
  },
})


const state = reactive({
  wtTaskVO: {
    taskName: "",
    taskDesc: "",
    taskType: undefined,
    taskStartTime: undefined,
    taskEndTime: undefined,
    taskLabel: undefined,
    predictWorkHours: undefined,
    remarks: undefined,
    taskWorkRatioLabel: undefined,
  },
  dictData: {}
})

const initDict = () => {
  const params = {
    dictFields: "WTTASKTYPE",
  };
  $api.common.getBatchDict.post(params).then((res) => {
    state.dictData = res.result;
  });
};

onMounted(() => {
  nextTick(() => {
    initDict();
    state.wtTaskVO = props.modelValue;
  });
});

watch(
    () => state.wtTaskVO,
    () => {
      emits("update:modelValue", state.wtTaskVO)
    }
)
</script>

<style scoped>

</style>